
#if($rsList)
    <script >
        var pathId = '$menuId';
        rescheckgroup();
    </script>
    <!-- new ui table -->
        <link rel="stylesheet" href="/javascript/theme/libs/jquery-easyui-1.4/themes/default/easyui.css" type="text/css" />
<script src="/javascript/theme/libs/jquery-easyui-1.4/jquery.easyui.min.js"></script>

    <div class="biui" style="OVERFLOW-X:yes;OVERFLOW-Y:auto">
        <div class="mail" id="mailsend" style="display:none;padding: 10px 10px 10px 10px;">
            <div class="mail-title">数据订阅<span><a href="javascript:void(0);" class="close-mail" style="padding-left: 5px;padding-top: 5px;">关闭</a></span></div>
				</br>
                <span style="padding-left: 15px;font-size: 11px;color: #ff0000;">1.系统会记录你最近一次查询本报表的筛选条件及查询字段，以邮件的形式定期将数据发送到订阅邮箱;</span>
				</br>
				<span style="padding-left: 15px;font-size: 11px;color: #ff0000;">2.可一次输入多个订阅邮箱，中间以英文分号隔开;</span>
				</br>
				<span style="padding-left: 15px;font-size: 11px;color: #ff0000;">3.订阅别名是指给该订阅邮件取个管理名，如描述之类的备忘信息等；</span>
				</br>
				<span style="padding-left: 15px;font-size: 11px;color: #ff0000;">4.在 个人中心 - 我的订阅邮件 中，可以对您订阅的邮件进行管理操作。</span>
				
                <div class="form-group" style="padding-left: 50px;padding-top: 30px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">订阅邮箱：</label>
                    <div class="col-md-2">
                      <input style="width:200px" type="text" id="emailAds" name="emailAds" class="form-control"/>
                    </div>
                </div>
                <input type="hidden"  id="freValue" name ="freValue" value=""/>
                <input type="hidden"  id="reportId" name ="reportId" value="$!{irReport.id}"/>
                <div class="form-group" style="padding-left: 50px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">订阅别名：</label>
                    <div class="col-md-2">
                    <input style="width:200px" type="text" id="subName" name="subName" class="form-control"/>
                    </div>
                </div>
                <div class="form-group" style="padding-left: 80px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">发送频率：</label>
                    <div class="col-md-2">
                        <input type="radio" name="sendFreRadio" id="sendFreRadio" onclick="sendFre('1')"/> 每日
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="radio" name="sendFreRadio" id="sendFreRadio" onclick="sendFre('2')"/> 每周
                    </div>
                </div>
                <div class="form-group" style="padding-left: 200px;padding-top: 20px;">
                    <button type="button" id="subMail" name ="subMail" class="btn btn-info btn-xs">确认订阅</button>
                </div>
        </div>
        
        <div class="mail" id="downdata" style="display:none;padding: 10px 10px 10px 10px;">
            <div class="mail-title">数据下载<span><a href="javascript:void(0);" class="close-mail" style="padding-left: 5px;padding-top: 5px;">关闭</a></span></div>
                </br>
                <span style="padding-left: 15px;font-size: 11px;color: #ff0000;">1.您导出的数据共有$!{querylength}行，因数据量过大，我们将在后端对该数据进行缓冲，完成后会有邮件提示，请留意您的邮箱；</span>
                </br>
				</br>
                <span style="padding-left: 15px;font-size: 11px;color: #ff0000;">2.您可以在下方对本次下载的数据文件起名，以方便管理；</span>
                </br>
				</br>
                <span style="padding-left: 15px;font-size: 11px;color: #ff0000;">3.您可以在  个人中心  - 我的下载  中查看所有的数据文件状态和进行下载。</span>
                </br></br></br></br>
                <div class="form-group" style="padding-left: 50px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">数据文件名：</label>
                    <div class="col-md-2">
                    <input style="width:200px" type="text" id="DownsubName" name="DownsubName" value="$!{irReport.reportName}" class="form-control"/>
                    </div>
                </div>
                <div class="form-group" style="padding-left: 200px;padding-top: 20px;">
                    <button type="button" id="DownsubData" name ="DownsubData" class="btn btn-info btn-xs">确认下载</button>
                </div>
        </div>


        <div class="panelhidden-bg" id="panelclose"></div>
        <div id="hoverChartDiv"  style="display: none;width: 97.5%; margin-left: 1.3%" class="chartviews">
            <div class="mail-title"><span><a href="javascript:void(0);" class="close-chart" style="padding-left: 7px;padding-top: 10px;">关闭</a></span></div>

            <div id="chartOption">
                <div class="content">
                        <form class="form-horizontal" role="form" id="search$!{pathId}_chart" name="search$!{pathId}_chart" action="/intreport/search/$!{pathId}" method="post" class="form-inline">
                            <div>
                                <div>
                                    <table class="biui-form">
                                        <tbody>
                                    <tr>
                                        <td class="topic"></td>
                                        <td class="context" id="td_chart_selects">                         
                                       
                                        <label class="text-head">指标:</label>
                                            <div class="text-body">
                                                <input type="hidden" id="chartvalues" initailVal="$!colsSelect"  name="chartvalues" value="$!colsSelect"/>  
                                                <select compType='chart_index' relname="chart_index" class="selectpicker show-tick form-control" data-live-search="false" multiple name="chart_index" id="chart_index" >
                                                #set($indexCount=0)
                                                #foreach($cname in $cnameList)
                                                    #set($name = $cname.split(':')[0])
                                                    #set($type = $cname.split(':')[1])
                                                    #if(($hasgraph)&&($type !=0) )
                                                        #set($indexCount = $indexCount + 1)
                                                        #set($ename = $cname.split(':')[2])
                                                     <option value="$ename" title="$name" #if($indexCount <= 5) selected #end >$name</option>
                                                    #end
                                                #end
                                                </select>
                                        </div>
                                        <button type="button" name="chartSearch" id="chartSearch" class="btn btn-warning btn-xs" >曲线图</button>
                                        <button type="button" name="pie_chartSearch" id="pie_chartSearch" class="btn btn-warning btn-xs" style="display:none" #if($cnameList.size() > 1) disabled #end >饼 图</button>                                     
                                        </td>
                                    </tr>

                                          </tbody>
                                    </table>
                                </div>
                            </div> 
                    </form>    
                </div>

            </div>
             
            <div id="chartdiv" style="margin: 0 auto;height:350px;" >
            </div>
        </div>

        <!-- <div class="panelhidden-bg" id="panelclose"></div> -->
        <div class="biui-table">
            <div class="head-title">
                <span>查询结果</span>
                <input type="hidden" id="querylengthfordown" name="querylengthfordown" value="$!{querylength}"/>
                <span class="tools"><span class="click-btn" id="download">导出excel</span></span>
                <span class="tools">
                    <input type="hidden" id="ordervalue" name="ordervalue" value=""/>
                    <input type="hidden" id="ordertype" name="ordertype" value=""/>
                </span>
                <div id="emailsubsend" class="mailbottomreturnTop"></div>

            #if($hasStatDate || $tools.getStrArrLen("$!groupBy",",") == 1)
                #if($!groupBy != "")
                <span class="tools" style="width:160px">
                    <span  id="chartview" class="click-btn">曲线/饼图绘制</span>
                </span>
                #end
            #end
            #if($hasStatDate)
                  <span class="tools"><span class="daterate">
                    环/同比:
                    <select size="1" name="dateratio" id="dateratio" onchange="selectRatio(this);">
                                <option value="" #if($dateratio=="") selected #end>无</option>
                                <option value="dayRatio" #if($dateratio=="dayRatio") selected #end>日环比</option>
                                <option value="weekRatio" #if($dateratio=="weekRatio") selected #end>周同比</option>
                                <option value="allRatio" #if($dateratio=="allRatio") selected #end>环同比</option>
                    </select>
                  </span></span> 
              #else
              <span class="tools"><span class="click-btn" id="DailyClick" onclick="selectDaily(this);">
                   <!-- 日均： -->
                   <input type="hidden" id="rijun" name="rijun" value="0"/>
                   #if($ordertype!="")
                        #if($dailyselect=="")
                         查看原始数据
                        <input type="hidden"  id="dailyselect" name ="dailyselect" value=""/>
                       #else
                         查看日均
                         <input type="hidden"  id="dailyselect" name ="dailyselect" value="dailyselect"/>
                       #end
                  #else
                       #if($dailyselect==""||$rijun==0)
                         查看日均
                         <input type="hidden"  id="dailyselect" name ="dailyselect" value="dailyselect"/>
                       #else
                        查看原始数据
                        <input type="hidden"  id="dailyselect" name ="dailyselect" value=""/>
                       #end
                  #end
                  <!--  <select size="1" name="dailyselect" id="dailyselect" onchange="selectDaily(this);">
                                <option value="" #if($dailyselect=="") selected #end>无</option>
                                <option value="dayRatio" #if($dailyselect=="dayRatio") selected #end>日均</option>
                   </select>  -->
              </span></span>    
               #end
            </div>
            <!-- <div class="second-title">
              
            </div> -->
            <div class="">
                <table class="bitable" data-provide="datatable" data-display-rows="20">
                    <thead> 
                        <tr>
                           <!--  $menuId -->
                            #foreach($cname in $cnameList)
                                #set($name = $cname.split(':')[0])
                                #set($type = $cname.split(':')[1])
                                #if(($type !=0)&&($tools.getStrArrLen($cname,":")>2))
                                #set($tipid = $cname.split(':')[2])
                                #else
                                #set($tipid = '')
                                #end 
                                <th>
                                    <div>
                                    <div class="divTip" tipid='$tipid'>
                                    $name
                                    </div>
                                    #if(($type !=0)&&($tools.getStrArrLen($cname,":")>2))
                                    #set($valname = $cname.split(':')[2])
                                        <span clickname="suborder" class="click-btn" columnname='$valname'>
                                            #if(($ordervalue)&&($ordervalue==$valname))
                                              #if($ordertype=='asc')
                                              <i id="tabletype" class="tabledown" ></i>
                                              #else
                                              <i id="tabletype" class="tableup" ></i>
                                              #end
                                            #else
                                              <i id="tabletype" class="tablebegin" ></i>
                                            #end
                                        </span>
                                       
                                    #end  
                                    </div>
                                </th>
                            #end
                        </tr>
                    </thead>

                    <tbody>
                        #foreach($rs in $rsList)
                            <tr>
                                #set($values = $rs.split(';'))
                                #foreach($value in $values)
                                    #set($result = $value.split(",")[0])
                                    #set($type = $value.split(",")[1])
                                    #set($initialValue = $value.split(",")[2])
                                    #set($weekrad = false)
                                    #set($dayrad = false)
                                    #if($result == 'total')
                                        #set($result = '总计')
                                    #end
                                    #if(($dateratio)&&($dateratio!=""))
                                      #if($dateratio=="dayRatio")
                                       #set($dayrad = true)
                                      #elseif($dateratio=="weekRatio")
                                       #set($weekrad = true)
                                      #elseif($dateratio=="allRatio")
                                       #set($weekrad = true)
                                       #set($dayrad = true)
                                      #end
                                    #end
                                    #if($type == 0)
                                        <td val="$initialValue" onclick="drilltdclick(this)">
                                            
                                            #if($tools.getStrArrLen($value,",")>3)
                                             #if($value.split(",")[3]!="no")
                                                <i class="add-icon on" data-value="$value"></i>
                                             #end 
                                            #end
                                            ${result}
                                           
                                        </td>
                                    #elseif($type == 1)
                                        <td>$tools.comInt($result)
                                        #if(($dateratio)&&($dateratio!=""))
                                        <br/>
                                        $tools.comRatio($gbValueMap,$rs,${result},$gbCount,$velocityCount,$dayrad,$weekrad,$statgrpindex)
                                        #end
                                        </td>
                                    #elseif($type == 2)
                                        <td>$tools.comFloat($result)
                                        #if(($dateratio)&&($dateratio!=""))<br/>$tools.comRatio($gbValueMap,$rs,${result},$gbCount,$velocityCount,$dayrad,$weekrad,$statgrpindex)#end</td>
                                    #elseif($type == 3)
                                        <td>$tools.comRate($result)
                                        #if(($dateratio)&&($dateratio!=""))<br/>$tools.comRatio($gbValueMap,$rs,${result},$gbCount,$velocityCount,$dayrad,$weekrad,$statgrpindex)#end</td>
                                    #end
                                #end
                            </tr>   
                        #end
                    </tbody>

                </table>

                <div class="row dt-rb">
                    #parse("/views/default/biuiPage.vm")
                    #pagenew($pList "/intreport/search/$menuId?#page#&$paramurl")
                </div>
            </div>
        </div>  
    </div>

	<script type="text/javascript">
        var drillFunction = function (parent) {
            var addNum = 0;
            if (!parent) {
                $('.add-icon').each(function(){
                    $(this).attr('data-num',addNum);
                    addNum++;
                });
            } else {
                $('.drill-table[data-parent="' + parent + '"]').each(function(){
                    $(this).find('.add-icon').attr('data-num', parent + '-' + addNum);
                    addNum++;
                });
            };

            var addObj = !parent ? $('.add-icon') : $('.drill-table[data-parent="' + parent + '"]').find('.add-icon');
            addObj.on('click',function(event){
                event.stopPropagation(); 
                var t = $(this);
                if (t.hasClass('on')) {
                    $.post('../drill/'+pathId, { drillCol: $(this).attr('data-value') }, function(json){
                        var addStr = '';
                        if(typeof(json.data)=='string')
                        {
                           addStr='<tr class="drill-table" data-parent="'+t.attr('data-num')+'"><td>已无数据可以钻取！</td></tr>';
                           t.parent().parent().after(addStr);
                           t.removeClass('on');
                        }else
                        {
                            var leftcount=0;  
                            leftcount=t.attr('data-num').split('-').length * 5;  
                            var colorriver="";
                            if(t.attr('data-num').split('-').length==2)
                            {
                                 colorriver='style="background-color: #ddd;"';
                            }else if(t.attr('data-num').split('-').length==3)
                            {
                                 colorriver='style="background-color: #ccc;"';
                            }else if(t.attr('data-num').split('-').length>3)
                            {
                                 colorriver='style="background-color: #ddd;"';
                            }
                            for (var i = 0, l = json.data.length; i < l; i++) {
                                addStr += '<tr class="drill-table" data-parent="'+t.attr('data-num')+'" '+colorriver+' >';
                                for (var j in json.data[i]) {
                                    addStr += '<td data-key="' + j + '" onclick="drilltdclick(this)">';
                                    if(typeof(json.data[i][j])=='object')
                                    {
                                     addStr +='<i class="add-icon on" data-value="'+json.data[i][j].tag+'" style=left:' + leftcount + 'px></i>';
                                     addStr += json.data[i][j].data + '</td>';
                                    }else{
                                    addStr += json.data[i][j] + '</td>';
                                    }
                                }
                                addStr += '</tr>';
                            }

                            t.parent().parent().after(addStr);
                            t.removeClass('on');
                            drillFunction(t.attr('data-num'));
                         }
                    },'json');
                } else {
                    t.parent().parent().parent().find('tr[data-parent="'+t.attr('data-num')+'"]').remove();

                    t.addClass('on');
                    var n=0;
                    while(n<50)
                    {
                        if(t.parent().parent().parent().find('tr[data-parent="'+t.attr('data-num')+'-'+n+'"]').length>0)
                            {
                                t.parent().parent().parent().find('tr[data-parent="'+t.attr('data-num')+'-'+n+'"]').remove();
                            }
                        var m=0;
                        while(m<50)
                         {
                           if(t.parent().parent().parent().find('tr[data-parent="'+t.attr('data-num')+'-'+n+'-'+m+'"]').length>0)
                              {
                                t.parent().parent().parent().find('tr[data-parent="'+t.attr('data-num')+'-'+n+'-'+m+'"]').remove();
                              }
                              m=m+1;
                          }

                             n=n+1;
                    }
                }
            });     
        };
        drillFunction();	

        
	</script>  
#end


	